package com.frxuexi.user.repository

import com.frxuexi.lib_base.BaseEntity
import com.frxuexi.lib_base.BaseRepository
import com.frxuexi.lib_http.HttpType
import com.frxuexi.lib_http.NetWorkFactory
import com.frxuexi.user.ApiService
import com.frxuexi.user.entity.ApproveEntity
import kotlinx.coroutines.flow.Flow
import okhttp3.RequestBody
import retrofit2.http.Body
import javax.inject.Inject

@OptIn
class UserNetRepo @Inject constructor():BaseRepository() {

    val apiService by lazy { NetWorkFactory.factory(HttpType.NEW).create(ApiService::class.java) }
    val apiServiceToken by lazy { NetWorkFactory.factory(HttpType.TOKEN).create(ApiService::class.java) }
    fun addEmployee(map: Map<String,Any>):Flow<BaseEntity<Any>>{
        return apiService.addEmployee(mapToJson(map))
    }

    fun login(map: Map<String,String>):Flow<BaseEntity<String>>{
        return apiService.login(mapToJson(map))
    }

    fun addApprove(map: Map<String,Any>):Flow<BaseEntity<Any>>{
        return apiServiceToken.addApprove(mapToJson(map))
    }

    fun getApprs(status:String):Flow<BaseEntity<List<ApproveEntity>>>{
        return apiServiceToken.getApprs(status)
    }

    fun approve(map: Map<String,Any>):Flow<BaseEntity<Any>>{
        return apiServiceToken.approve(mapToJson(map))
    }
}